﻿
$(function () {
    $("input,select").attr({ "autocomplete": "off" })
    $("input[type='password']").attr({ "autocomplete": "new-password" })
    if ($("#Login_path").text() == "") {
        $("#Browsing_path").val("C:\\Users\\Public\\Documents")
    }
})
$(document).on("click", "#HOME_Settings", function () {
    $("#Setup_panel").css({ "display": "block" });
})
$(document).on("click", "#Setup_panel_quit", function () {
    $("#Setup_panel").css({ "display": "none" });
})
$(document).on("click", "#Path_change", function () {
    $.ajax({
        url: '/Material/SelectFilePath',
        type: 'POST',
        data: { "shu": 1 },
        success: function (path) {
            $("#Browsing_path").val(path)
        },
        error: function () {
            alert("系统错误!");
        }
    })
})


$(document).on("click", "#Setup_panel_OK", function () {
    var fileUpload = $('#file1')[0];
    if (fileUpload.files.length > 0) {
        var fileData = new FormData();
        fileData.append('file', fileUpload.files[0]);
        $.ajax({
            url: '/Contracts/AddNdardo',
            type: 'POST',
            contentType: false, // 不设置内容类型  
            processData: false, // 不处理数据  
            data: fileData,
            success: function (response) {
                var sjinf = $("#Login_name").val()
                var dal = {
                    "DE_ID": sjinf,
                    "DE_dizhi": response
                }
                $.ajax({
                    url: '/Material/Modify_Download_path',
                    type: 'POST',
                    data: { "dl": dal },
                    success: function (response) {

                    },
                    error: function (jqXHR, textStatus, errorMessage) {
                        alert('AJAX请求失败：' + errorMessage);
                    }
                });
            },
            error: function (jqXHR, textStatus, errorMessage) {
                alert('AJAX请求失败：' + errorMessage);
            }
        });


    }
})
$(document).on("click", "#Submitss", function () {
    var oldpwd = $("#oldpwd").val()
    var newpwd = $("#newpwd").val()
    var newpwd2 = $("#newpwd2").val()
    $.ajax({
        url: "/Material/ChagnPwd",
        type: "POST",
        data: { "oldpwd": oldpwd, "newpwd": newpwd, "newpwd2": newpwd2 },
        success: function (path) {
            $("#newpwd2_l").text(path)
        },
        error: function (path) {
            alert("系统错误!");
        }
    })
})
$(document).ready(function () {
    $("#ulij>li>h6").click(function () {
        $(this).next("ul").toggle()
    }/*,function () {
        $(thiss).children("ul").stop(true).slideUp(500)
    }*/)

})
$(document).ready(function () {
    setInterval(function () {
        var now = moment();
        var dateTimeFormat = 'YYYY-MM-DD HH:mm:ss'; // 设置日期和时间的格式
        $('#date-time').text(now.format(dateTimeFormat)); // 更新div元素的内容
    }, 1000); // 每秒更新一次
});
function sjin() {
    var newpwd2 = $("#LoUid").val()
    $.ajax({
        url: "/Material/ChagnPwd",
        type: "POST",
        data: {},
        success: function (path) {
            $("#newpwd2_l").text(path)
            window.location = true;
        },
        error: function (path) {
            alert("系统错误!");
        }
    })

}
$(document).ready(function () {
    function JNSa() {
        var shu = $("#Login_sf").text()
        if (shu == "" || shu == null) {
            alert("权限到期，请重新登录！")
            window.location.href = "/Home/tuichu?id=" + tui;
        }
    };
    setInterval(JNSa, 6000); // 一分钟更新一次
});

/*//__全屏 关闭全屏
//全屏
$(document).ready(function () {
    $(document).trigger($.Event("keydown", { keyCode: 122, which: 122 }));
});*/
//=--=-=-=-=-=-=--=-=--=-==-=-===
//弹出窗拖动功能
$(document).ready(function () {
    var deltax = 0, deltay = 0;
    var shunf = $(".Tuodong").parent()

    $('.Tuodong').mousedown(function (event) {
        deltax = event.pageX - $(this).parent().offset().left;
        deltay = event.pageY - $(this).parent().offset().top;
        $(document).on('mousemove', start)
        $(document).on('mouseup', end)
        return false
    })
    function start(event) {
        x = event.clientX - deltax
        y = event.clientY - deltay
        $(shunf).css({ 'left': x + 'px', 'top': y + 'px' })
        return false
    }
    function end(event) {
        $(this).unbind('mousemove')
        $(this).unbind('mouseup')
    }
})

//全局变量
window.onbeforeunload = function (e) {
    var id = $("#Login_name").text()
    $.ajax({
        url: '/Home/Index',
        type: 'POST',
        data: { "shund": id, "states": 13 },
        success: function (date) {

        }, error: function () {
            alert("系统错误")
        }
    })
}
